package cn.com.skbang.backend.user.service.admin.controller;

import cn.com.skbang.backend.user.service.admin.biz.AdminTeacherBiz;
import cn.com.skbang.backend.user.service.admin.req.AdminLecturerEditReq;
import cn.com.skbang.backend.user.service.admin.req.AdminLecturerPageReq;
import cn.com.skbang.backend.user.service.admin.req.AdminLecturerSaveReq;
import cn.com.skbang.backend.user.service.admin.resp.AdminLecturerPageResp;
import cn.com.skbang.backend.user.service.admin.resp.AdminLecturerViewResp;
import cn.com.skbang.backend.common.core.base.Page;
import cn.com.skbang.backend.common.core.base.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;

/**
 * ADMIN-讲师信息
 *
 * @author wujing
 */
@Api(tags = "ADMIN-讲师信息")
@RestController
@RequiredArgsConstructor
//TODO xupc /user/admin/lecture -> /user/admin/teacher
@RequestMapping("/user/admin/teacher")

//TODO xupc AdminLectureContooler -> AdminTeacherController
public class AdminTeacherController {

    @NotNull
    private final AdminTeacherBiz biz;

    @ApiOperation(value = "讲师信息分页", notes = "讲师信息分页")
    @PostMapping(value = "/page")
    public Result<Page<AdminLecturerPageResp>> page(@RequestBody AdminLecturerPageReq req) {
        return biz.page(req);
    }

    @ApiOperation(value = "讲师信息添加", notes = "讲师信息添加")
    @PostMapping(value = "/save")
    public Result<String> save(@RequestBody @Valid AdminLecturerSaveReq req) {
        return biz.save(req);
    }

    @ApiOperation(value = "讲师信息查看", notes = "讲师信息查看")
    @ApiImplicitParam(name = "id", value = "主键ID", dataTypeClass = Long.class, paramType = "query", required = true)
    @GetMapping(value = "/view")
    public Result<AdminLecturerViewResp> view(@RequestParam Long id) {
        return biz.view(id);
    }

    @ApiOperation(value = "讲师信息修改", notes = "讲师信息修改")
    @PutMapping(value = "/edit")
    public Result<String> edit(@RequestBody @Valid AdminLecturerEditReq req) {
        return biz.edit(req);
    }

    @ApiOperation(value = "讲师信息删除", notes = "讲师信息删除")
    @ApiImplicitParam(name = "id", value = "主键ID", dataTypeClass = Long.class, paramType = "query", required = true)
    @DeleteMapping(value = "/delete")
    public Result<String> delete(@RequestParam Long id) {
        return biz.delete(id);
    }
}
